<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>按钮</button>

  <script>
    /**
     * elem.onevent
     *  ● 每种事件只能有一个事件监听函数
     */
    const elem = document.querySelector('button')

    // 注册事件监听
    elem.onclick = function () {
      console.log('onclick')
    }

    // 注销事件监听
    elem.onclick = null
  </script>
</body>

</html>